#ifndef TRANSPARENTTIMER_H
#define TRANSPARENTTIMER_H

#include <QWidget>
#include <QTimer>
#include <QElapsedTimer>
#include <QMouseEvent>
#include <QIntValidator>
#include <QPushButton>
#include <QApplication>
#include <QPainter>
#include <QLinearGradient>
#include <QProxyStyle>
#include <QStyleOption>
#include <QLabel>

class QLabel;

// 窗口边缘大小（用于调整窗口）
#define BORDER_WIDTH 8

class TransparentTimer : public QWidget
{
Q_OBJECT

public:
    TransparentTimer(QWidget *parent = nullptr);

protected:
    void paintEvent(QPaintEvent *event) override;
    void mousePressEvent(QMouseEvent *event) override;
    void mouseMoveEvent(QMouseEvent *event) override;
    void mouseReleaseEvent(QMouseEvent *event) override;

private slots:
    void updateTimer();
    void toggleTimer();
    void resetTimer();
    void toggleTopmost();
    void calculateRate();

private:
    void updateCursorShape(const QPoint &point);
    void updateMouseRegion();

    static const QString c_iconPath;
    QTimer *timer;
    QElapsedTimer elapsedTimer;
    bool isRunning = false;
    bool isTopmost = false;
    double elapsedSeconds = 0;
    double totalSeconds = 0;
    int rate = 0;
    int problemCount = 0;
    int fontSize = 42;
    QPoint dragPosition;
    bool isResizing = false;
    int resizeRegion = 0; // 0=无, 1=上, 2=下, 3=左, 4=右, 5=左上, 6=右上, 7=左下, 8=右下

    // UI 元素
    QWidget *mainWidget;
    QLabel *timeLabel;
    QLineEdit *problemInput;
    QLabel *rateLabel;
    QPushButton *startButton;
    QPushButton *resetButton;
    QPushButton *topButton;
    QPushButton *closeButton;
    QPushButton *minimizeButton;
};

#endif // TRANSPARENTTIMER_H